package robot;

/**
 * Class Edit.
 * This class represent a basic edit of the Blip message. With the starting and 
 * the ending index of the Emoticon code that will be changed with the Emoticon 
 * Image wrapped into this istance.
 * @author Mirko Bonadei
 * @version 0.1
 */
public class Edit implements Comparable<Object>{
	
	protected int startIndex, endIndex;
	protected Emoticon emoticon;
	
	public Edit(int startIndex, int endIndex, Emoticon emoticon){
		this.startIndex = startIndex;
		this.endIndex = endIndex;
		this.emoticon = emoticon;
	}
	
	public int getStartIndex(){
		return this.startIndex;
	}
	
	public int getEndIndex(){
		return this.endIndex;
	}
	
	public Emoticon getEmoticon(){
		return this.emoticon;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("Start:" + this.startIndex + "\t");
		sb.append("End:" + this.endIndex + "\t");
		sb.append("Code:" + this.emoticon.getCode() + "\n");
		return sb.toString();
	}

	@Override
	public int compareTo(Object o) {
		Edit tmp = (Edit) o;
		if(this.startIndex < tmp.getStartIndex()){
			return 1;
		}else if(this.startIndex > tmp.getStartIndex()){
			return -1;
		}else{
			return 0;
		}
	}

}
